// grandson.js 组件
import React from 'react';
import { Consumer } from './Father';
import { Consumer as ShowConsumer } from './showContext';

export default class Grandson extends React.Component {
    render () {
        return (
            <Consumer>
                {
                    ({ name, age }) => (
                        <div>
                            <p>孙组件。获取传递下来的值: {name} - {age}</p>
                            <ShowConsumer>
                                {
                                    ({ name, age }) => (
                                        <div>
                                            孙组件自己的Context: &nbsp;
                                            {name} - {age}
                                        </div>
                                    )
                                }
                            </ShowConsumer>
                        </div>
                    )
                }
            </Consumer>
        );
    }
}
